package org.ewaf.framework.ibatis.type;

import java.sql.SQLException;

import com.ibatis.sqlmap.client.extensions.ResultGetter;
import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback;

public abstract class FuzzyQueryTypeHandlerCallback implements TypeHandlerCallback {

	public Object getResult(ResultGetter getter) throws SQLException {
		return new UnsupportedOperationException();
	}

	public Object valueOf(String s) {
		return s;
	}
	
	protected String escape(Object parameter) {
		String s = (String) parameter;
		
		s = s.replace("\\", "\\\\");
		s = s.replace("%", "\\%");
		return s.replace("_", "\\_");
	}

}
